var reg = new RegExp(",","g"),
win1 = null,
win2 = null,
win3 = null,
win4 = null,
strs = "",
st= "",
str = "",
text = "",
val = "",
label = [],
value = [],
//结构性资产项

//可供出售金融资产
 kgcsjrzc = 8374,　
//固定资产
gdzc = 8334,
//无形资产
wxzc = 5373,
//持有至到期投资
cyzdqtz = 34565,
//长期应收款
cqysk = 4757,
//长期股权投资
cqgqtz = 67434,
//投资性房地产
tzxfdc = 1550,
//在建工程
zjgc = 1593,
//工程物资
gcwz = 5004,
//固定资产清理
gdzcql = 3450,
//生产性生物资产
scxswzc = 6600,
//油气资产
yqzc = 34455,
//开发支出
kfzc = 7845,
//商誉
sy = 4578,
//长期待摊费用
cqdtfy = 4554,
//递延所得税资产
dysdszc = 45478,
//其他非流动资产
qtfldzc = 4544,

//结构性资产：可供出售金融资产+持有至到期投资+长期应收款+长期股权投资+投资性房地产+固定资产+在建工程+工程物资+固定资产清理+生产性生物资产+油气资产+无形资产+开发支出+商誉+长期待摊费用+递延所得税资产+其他非流动资产（资产负债表期末数）
jgxzc =kgcsjrzc+cyzdqtz+cqysk+cqgqtz+tzxfdc+gdzc+zjgc+gcwz+gdzcql+scxswzc+yqzc+wxzc+kfzc+sy+cqdtfy+dysdszc+qtfldzc,

//除去结构性资产中的可供出售金融资产
jgxzc1 = cyzdqtz+cqysk+cqgqtz+tzxfdc+gdzc+zjgc+gcwz+gdzcql+scxswzc+yqzc+wxzc+kfzc+sy+cqdtfy+dysdszc+qtfldzc,
//除去固定资产的结构性资产
jgxzc2 =kgcsjrzc+cyzdqtz+cqysk+cqgqtz+tzxfdc+zjgc+gcwz+gdzcql+scxswzc+yqzc+wxzc+kfzc+sy+cqdtfy+dysdszc+qtfldzc,
//除去无形资产的结构性资产
jgxzc3 =kgcsjrzc+cyzdqtz+cqysk+cqgqtz+tzxfdc+gdzc+zjgc+gcwz+gdzcql+scxswzc+yqzc+kfzc+sy+cqdtfy+dysdszc+qtfldzc,


//结构性负债项

//长期借款
cqjk = 1234,
//股本
gb = 10065,
//未分配利润
wfplr = 800,


//实收资本
sszb = 900,
//资本公积
zbgj = 10033,
//减：库存股
jkcg = 100,
//盈余公积
yygj = 100,
//少数股东权益
ssgdqy = 100,
//应付债券
yfzq = 100,
//长期应付款
cqyfk = 100,
//专项应付款
zxyfk = 100,
//预计负债
yjfz = 1450,
//递延所得税负债
dysdsfz = 100,
//其他非流动负债
qtfldfz = 100,

//结构性负债：实收资本+资本公积-减：库存股+盈余公积+未分配利润+*少数股东权益+长期借款+应付债券+长期应付款+专项应付款+预计负债+递延所得税负债+其他非流动负债（资产负债表期末数）
jgxfz = sszb + zbgj - jkcg + yygj + wfplr +ssgdqy+ gb + cqjk + yfzq+cqyfk+zxyfk+yjfz+dysdsfz+qtfldfz,

//经营性资产项

//应收账款
yszk = 4348,
//其它应收款
qtysk = 4543,
//存货
ch = 5435,
//预付款项
yfkx = 4578,
//应收股利
ysgl = 1000,
//应收利息
yslx = 3430,
//一年内到期的非流动资产
ynn = 4859,
//其他流动资产
qtldzc = 100,
//经营性资产：应收账款+ 预付款项+应收利息+ 应收股利+其他应收款+存货+一年内到期的非流动资产+其他流动资产
jyxzc = yszk + yfkx + yslx + ysgl + qtysk + ch + ynn + qtldzc,


//经营性负债项

//应付账款 
yfzk = 5600,

//应付员工薪酬
yfzgxc = 4558,

//其他应付款
qtyfk = 4535,

//应交税费
yjsf = 7654,

//应付利息
yflx = 3458,

//应付股利
yfgl = 7687,

//一年内到期的非流动负债
ynnn = 4548,
//其他流动负债
qtldfz = 4595,

//经营性负债：应付账款+预收款项+应付职工薪酬+应交税费+ 应付利息+ 应付股利+其他应付款+一年内到期的非流动负债+其他流动负债（资产负债表期末数）
jyxfz = yfzk + yfkx + yfzgxc + yjsf + yflx + yfgl + qtyfk + ynnn + qtldfz,


//营运资本：结构性负债-结构性资产
yyzb = jgxfz - jgxzc,


//营运资金需求：经营性资产-经营性负债
yyzjxq = jyxzc - jyxfz,

//现金支付能力 = 营运资本 - 营运资金需求
xjzfnl = yyzb - yyzjxq;

Ext.onReady(function(){

//		Ext.Ajax.request({
//
//				url : 'http://192.168.0.135:8080/test/getcommomdataservlets',
//				method : 'GET',
//				params : {
//					test : "1",
//					month : "02",
//					year : "2010",
//					testCode : "GS000002",
//					unit : "3",
//					flag : true
//				},
//				success : function(res) {
//
//					init();
//
//				},
//				failure : function(res) {
//					
					init();
					initInputData();

//				},
//				scope : this
//
//			});
	
	
	
//	$.ajax({
//		
//		url:'../../GetDataServer.do?timeStamp='+new Date().getTime(),
//		
//		type:'GET',
//
//		data:"code=GS000002&unit=3&month=03&year=2010&testCode=GS000002&test=1",
//	
//		dataType:"json",
//		
//		async:true,
//		
//		success:function(data,response){
//		
//			//initByData(data);	
//		
//
//		},
//		error:function(){
//			
//			alert("连接数据库失败,采用本地数据");
			
				
//		}
//		
//	
	//});
		
//	document.onreadystatechange = function(){  
//        if(document.readyState=="complete")  
//        {  
//     	 //$("html").unmask();
//   		//$(".document").show('2000');
//        }
//	};

});
	




function init(){

		//可供出售金融资产
		var kgcsjrzcobj = new Ext.slider.SingleSlider({
				renderTo : 'kgcsjrzcId',
				id : 'kgcsjrzc',
				width : 100,
				anchor : '100%',
				title:'可供出售金融资产',
				increment : 1,
				minValue : -500000,
				maxValue :500000,
				value : kgcsjrzc,
				listeners : {
					
					dragend : function(slider, e, eOpts) {
							
							updateSelfInput(slider);
							
							val =  slider.getValue();
							
							updateJGXZC();
											

					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							
							updateSelfInput(slider);
							
							kgcsjrzc = slider.getValue();
													
							wxzc = Ext.getCmp("wxzc").getValue();
							
							if(wxzc <= 0){
								
									wxzc = 0;
							
							}
							
							gdzc = Ext.getCmp("gdzc").getValue();
							
							if(gdzc <= 0){
							
								gdzc = 0;
								
							}
							
							if(val > 0){
								
									label=['可供出售金融资产','持有至到期投资','长期应收款','长期股权投资','投资性房地产','固定资产','在建工程','工程物资','固定资产清理','生产性生物资产','油气资产','无形资产','开发支出','商誉','长期待摊费用','递延所得税资产','其他非流动资产'];

									value=[kgcsjrzc,cyzdqtz,cqysk,cqgqtz,tzxfdc,gdzc,zjgc,gcwz,gdzcql,scxswzc,yqzc,wxzc,kfzc,sy,cqdtfy,dysdszc,qtfldzc];
	
									create2DPie("chart1",label,value,"pie1",0,1);	
							
									create2DPies("chart11",label,value,"newpie1",1);
								
							}else{
							
									//Ext.Msg.alert("温馨提示",slider.title+"已≤0,系统将按0计算");
									
									label=['可供出售金融资产','持有至到期投资','长期应收款','长期股权投资','投资性房地产','固定资产','在建工程','工程物资','固定资产清理','生产性生物资产','油气资产','无形资产','开发支出','商誉','长期待摊费用','递延所得税资产','其他非流动资产'];
	
									value=["0",cyzdqtz,cqysk,cqgqtz,tzxfdc,gdzc,zjgc,gcwz,gdzcql,scxswzc,yqzc,wxzc,kfzc,sy,cqdtfy,dysdszc,qtfldzc];
		
									create2DPie("chart1",label,value,"pie1",0,1);
									create2DPies("chart11",label,value,"newpie1",1);
							}
							
							
							
							updateJGXZC();

					},
					change : function(slider, newValue, thumb, eOpts) {
    						
    						updateSelfInput(slider);
    						    						
							updateJGXZC();

					},
					scope : this
				}
			});

	
	
		
		
		//固定资产
			
		var gdzcobj = new Ext.slider.SingleSlider({
				renderTo : 'gdzcId',
				id : 'gdzc',
				width : 100,
				anchor : '100%',
				increment : 1,
				title:'固定资产',
				minValue : -500000,
				maxValue :500000,
				value : gdzc,
				listeners : {
					dragend : function(slider, e, eOpts) {
							updateSelfInput(slider);
			
							updateJGXZC();

					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							
							gdzc =  slider.getValue();
							
							kgcsjrzc = Ext.getCmp("kgcsjrzc").getValue();
							
							if(kgcsjrzc <= 0){
							
								kgcsjrzc = 0;
							
							}
							
							wxzc = Ext.getCmp("wxzc").getValue();
							
							if(wxzc <= 0){
							
								wxzc = 0;
							
							}
							
							if(gdzc >= 0){
								
									label=['可供出售金融资产','持有至到期投资','长期应收款','长期股权投资','投资性房地产','固定资产','在建工程','工程物资','固定资产清理','生产性生物资产','油气资产','无形资产','开发支出','商誉','长期待摊费用','递延所得税资产','其他非流动资产'];

									value=[kgcsjrzc,cyzdqtz,cqysk,cqgqtz,tzxfdc,gdzc,zjgc,gcwz,gdzcql,scxswzc,yqzc,wxzc,kfzc,sy,cqdtfy,dysdszc,qtfldzc];
	
									create2DPie("chart1",label,value,"pie1",0,1);	
							create2DPies("chart11",label,value,"newpie1",1);
									
								
							}else{
							
								//Ext.Msg.alert("温馨提示",slider.title+"已小于0,系统将按0计算");
								
								label=['可供出售金融资产','持有至到期投资','长期应收款','长期股权投资','投资性房地产','固定资产','在建工程','工程物资','固定资产清理','生产性生物资产','油气资产','无形资产','开发支出','商誉','长期待摊费用','递延所得税资产','其他非流动资产'];

								value=[kgcsjrzc,cyzdqtz,cqysk,cqgqtz,tzxfdc,'0',zjgc,gcwz,gdzcql,scxswzc,yqzc,wxzc,kfzc,sy,cqdtfy,dysdszc,qtfldzc];
	
								create2DPie("chart1",label,value,"pie1",0,1);
							create2DPies("chart11",label,value,"newpie1",1);
							}
							
						updateJGXZC();

					},
					change : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);	
							updateJGXZC();
					},
					scope : this
				}
			});	
			
		
		//无形资产
			var wxzcobj = new Ext.slider.SingleSlider({
				renderTo : 'wxzcId',
				id : 'wxzc',
				width : 100,
				anchor : '100%',
				increment : 1,
				title:'无形资产',
				minValue : -500000,
				maxValue :500000,
				value : wxzc,
				listeners : {
					dragend : function(slider, e, eOpts) {
							updateSelfInput(slider);
							updateJGXZC();

					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							
							wxzc =  slider.getValue();
							
							kgcsjrzc = Ext.getCmp("kgcsjrzc").getValue();
							
							if(kgcsjrzc <= 0){
							
								kgcsjrzc = 0;
							
							}
							
							gdzc = Ext.getCmp("gdzc").getValue();
							
							if(gdzc <= 0){
							
								gdzc = 0;
							
							}
							
							if(wxzc  > 0){
								
									label=['可供出售金融资产','持有至到期投资','长期应收款','长期股权投资','投资性房地产','固定资产','在建工程','工程物资','固定资产清理','生产性生物资产','油气资产','无形资产','开发支出','商誉','长期待摊费用','递延所得税资产','其他非流动资产'];

									value=[kgcsjrzc,cyzdqtz,cqysk,cqgqtz,tzxfdc,gdzc,zjgc,gcwz,gdzcql,scxswzc,yqzc,wxzc,kfzc,sy,cqdtfy,dysdszc,qtfldzc];
	
									create2DPie("chart1",label,value,"pie1",0,1);	
									create2DPies("chart11",label,value,"newpie1",1);
									
								
							}else{
							
								//Ext.Msg.alert("温馨提示",slider.title+"已小于0,系统将按0计算");
								
								label=['可供出售金融资产','持有至到期投资','长期应收款','长期股权投资','投资性房地产','固定资产','在建工程','工程物资','固定资产清理','生产性生物资产','油气资产','无形资产','开发支出','商誉','长期待摊费用','递延所得税资产','其他非流动资产'];

								value=[kgcsjrzc,cyzdqtz,cqysk,cqgqtz,tzxfdc,gdzc,zjgc,gcwz,gdzcql,scxswzc,yqzc,'0',kfzc,sy,cqdtfy,dysdszc,qtfldzc];
	
								create2DPie("chart1",label,value,"pie1",0,1);
								create2DPies("chart11",label,value,"newpie1",1);
							}
							
							
							
							updateJGXZC();

					},
					change : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJGXZC();

					},
					scope : this
				}
			});	
		
		
		//长期借款
			var cqjkobj = new Ext.slider.SingleSlider({
				renderTo : 'cqjdId',
				id : 'cqjd',
				width : 100,
				anchor : '100%',
				increment : 1,
				title:'长期借款',
				minValue : -500000,
				maxValue :500000,
				value :cqjk,
				listeners : {
					dragend : function(slider, e, eOpts) {
							updateSelfInput(slider);
							updateJGXFZ();

					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJGXFZ();
						
								//长期借款
							 	cqjk = slider.getValue();
							 	
							 	//股本
							 	ssgdqy = $("#gbIdinput").val().replace(reg,"") - 0;
							 	
							 	if(ssgdqy <= 0){
							 	
							 		ssgdqy = 0 ; 
							 		
							 	}
								//未分配利润
								wfplr = $("#wfplrIdinput").val().replace(reg,"") - 0;
								
								if(wfplr <= 0 ){
								
									wfplr = 0 ;
									
								}
								
							 	if(cqjk > 0){
						
								 	label=['实收资本','资本公积','减：库存股','盈余公积','未分配利润','*少数股东权益','长期借款','应付债券','长期应付款','专项应付款','预计负债','递延所得税负债','其他非流动负债'];
								
									value=[sszb,zbgj,jkcg,yygj,wfplr,ssgdqy,cqjk,yfzq,cqyfk,zxyfk,yjfz,dysdsfz,qtfldfz];
									
									create2DPie("chart2",label,value,"pie2",0,1);	
									create2DPies("chart22",label,value,"newpie2",1);			
							 	
							 	}else{
							 	
							 		//Ext.Msg.alert("温馨提示",slider.title+"已≤0,系统将按0计算");
							 	
							 		label=['实收资本','资本公积','减：库存股','盈余公积','未分配利润','*少数股东权益','长期借款','应付债券','长期应付款','专项应付款','预计负债','递延所得税负债','其他非流动负债'];
								
									value=[sszb,zbgj,jkcg,yygj,wfplr,ssgdqy,'0',yfzq,cqyfk,zxyfk,yjfz,dysdsfz,qtfldfz];
									
									create2DPie("chart2",label,value,"pie2",0,1);	
												
							 		create2DPies("chart22",label,value,"newpie2",1);
							 	}
							 	

					},
					change : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJGXFZ();

					},
					scope : this
				}
			});	
		
		//股本
			var gbobj = new Ext.slider.SingleSlider({
				renderTo : 'gbId',
				id : 'gb',
				width : 100,
				anchor : '100%',
				increment : 1,
				title:'少数股东损益',
				minValue : -500000,
				maxValue :500000,
				value : gb,
				listeners : {
					dragend : function(slider, e, eOpts) {
							updateSelfInput(slider);
							updateJGXFZ();

					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJGXFZ();
						
							 	//股本
								ssgdqy = slider.getValue();
							
								//长期借款
								 cqjk = $("#cqjdIdinput").val().replace(reg,"") - 0;
								 	
								 	if( cqjk  <= 0){
								 	
								 		 cqjk  = 0 ; 
								 		
								 }
								//未分配利润
								wfplr = $("#wfplrIdinput").val().replace(reg,"") - 0;
								
								if(wfplr <= 0 ){
								
									wfplr = 0 ;
									
								}
								
							 	if(ssgdqy > 0){
						
								 	label=['实收资本','资本公积','减：库存股','盈余公积','未分配利润','*少数股东权益','长期借款','应付债券','长期应付款','专项应付款','预计负债','递延所得税负债','其他非流动负债'];
								
									value=[sszb,zbgj,jkcg,yygj,wfplr,ssgdqy,cqjk,yfzq,cqyfk,zxyfk,yjfz,dysdsfz,qtfldfz];
									
									create2DPie("chart2",label,value,"pie2",0,1);	
										create2DPies("chart22",label,value,"newpie2",1);			
							 	
							 	}else{
							 	
							 		//Ext.Msg.alert("温馨提示",slider.title+"已≤0,系统将按0计算");
							 	
							 		label=['实收资本','资本公积','减：库存股','盈余公积','未分配利润','*少数股东权益','长期借款','应付债券','长期应付款','专项应付款','预计负债','递延所得税负债','其他非流动负债'];
								
									value=[sszb,zbgj,jkcg,yygj,wfplr,'0',cqjk,yfzq,cqyfk,zxyfk,yjfz,dysdsfz,qtfldfz];
									
									create2DPie("chart2",label,value,"pie2",0,1);	
												
							 		create2DPies("chart22",label,value,"newpie2",1);
							 	}
							

					},
					change : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJGXFZ();

					},
					scope : this
				}
			});	
		
		//未分配利润
		var wfplrobj = new Ext.slider.SingleSlider({
				renderTo : 'wfplrId',
				id : 'wfplr',
				width : 100,
				anchor : '100%',
				increment : 1,
				title:'未分配利润',
				minValue : -500000,
				maxValue :500000,
				value : wfplr,
				listeners : {
					dragend : function(slider, e, eOpts) {
							updateSelfInput(slider);
							updateJGXFZ();
					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJGXFZ();
							
								//未分配利润
								wfplr = slider.getValue();
							
								//长期借款
								 cqjk = $("#cqjdIdinput").val().replace(reg,"") - 0;
								 	
								 	if( cqjk  <= 0){
								 	
								 		 cqjk  = 0 ; 
								 		
								 }
								//股本
								ssgdqy = $("#gbIdinput").val().replace(reg,"") - 0;
								
								if( ssgdqy<= 0 ){
								
									ssgdqy = 0 ;
									
								}
								
							 	if(wfplr > 0){
						
								 	label=['实收资本','资本公积','减：库存股','盈余公积','未分配利润','*少数股东权益','长期借款','应付债券','长期应付款','专项应付款','预计负债','递延所得税负债','其他非流动负债'];
								
									value=[sszb,zbgj,jkcg,yygj,wfplr,ssgdqy,cqjk,yfzq,cqyfk,zxyfk,yjfz,dysdsfz,qtfldfz];
									
									create2DPie("chart2",label,value,"pie2",0,1);	
										create2DPies("chart22",label,value,"newpie2",1);			
							 	
							 	}else{
							 	
							 		//Ext.Msg.alert("温馨提示",slider.title+"已≤0,系统将按0计算");
							 	
							 		label=['实收资本','资本公积','减：库存股','盈余公积','未分配利润','*少数股东权益','长期借款','应付债券','长期应付款','专项应付款','预计负债','递延所得税负债','其他非流动负债'];
								
									value=[sszb,zbgj,jkcg,yygj,'0',ssgdqy,cqjk,yfzq,cqyfk,zxyfk,yjfz,dysdsfz,qtfldfz];
									
									create2DPie("chart2",label,value,"pie2",0,1);	
									create2DPies("chart22",label,value,"newpie2",1);			
							 	
							 	}
							
							

					},
					change : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJGXFZ();

					},
					scope : this
				}
			});		
			
			
		
		
		//应收账款
		var yszkobj = new Ext.slider.SingleSlider({
				renderTo : 'yszkId',
				id : 'yszk',
				width : 100,
				anchor : '100%',
				increment : 1,
				minValue : -500000,
				maxValue :500000,
				value : yszk,
				title:'应收账款',
				listeners : {
					dragend : function(slider, e, eOpts) {
							updateSelfInput(slider);
 							updateJYXZC();

					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJYXZC();
							//应收账款
							yszk = slider.getValue();	
							//其他应收款
							qtysk = $("#qtyskIdinput").val().replace(reg,"") - 0;
							
							if(qtysk < 0){
								
								qtysk = 0;
								
							}
							
							//存货
							ch = $("#chIdinput").val().replace(reg,"") - 0;
							ch = ch < 0 ? 0 : ch ;
							
							if(yszk > 0 ){
							
								label=['应收账款','预付款项','应收利息','应收股利','其他应收款','存货','一年内到期的非流动资金','其他流动资金'];
				
								value=[yszk,yfkx,yslx,ysgl,qtysk,ch,ynn,qtldzc];
								
							
							
							
							}else{
							
								//Ext.Msg.alert("温馨提示",slider.title+"已≤0,系统将按0计算");
							
								label=['应收账款','预付款项','应收利息','应收股利','其他应收款','存货','一年内到期的非流动资金','其他流动资金'];
				
								value=['0',yfkx,yslx,ysgl,qtysk,ch,ynn,qtldzc];
								
									
							}	
							
							create2DPie("chart3",label,value,"pie3",0,1);	
		 					create2DPies("chart33",label,value,"newpie3",1);
							
							
							
							
							
					},
					change : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJYXZC();

					},
					scope : this
				}
			});		
				
			
			
		
		//其它应收款
		var qtyskobj = new Ext.slider.SingleSlider({
				renderTo : 'qtyskId',
				id : 'qtysk',
				width : 100,
				anchor : '100%',
				increment : 1,
				minValue : -500000,
				maxValue :500000,
				value :qtysk,
				title:'其它应收款',
				listeners : {
					dragend : function(slider, e, eOpts) {
							updateSelfInput(slider);
							updateJYXZC();
					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJYXZC();
							
							//应收账款
							yszk =$("#yszkIdinput").val().replace(reg,"") - 0;
							yszk = yszk < 0 ? 0 : yszk ;
							
							//其他应收款
							qtysk = slider.getValue();
							
							
							//存货
							ch = $("#chIdinput").val().replace(reg,"") - 0;
							ch = ch < 0 ? 0 : ch ;
							
							if(qtysk > 0 ){
							
								label=['应收账款','预付款项','应收利息','应收股利','其他应收款','存货','一年内到期的非流动资金','其他流动资金'];
				
								value=[yszk,yfkx,yslx,ysgl,qtysk,ch,ynn,qtldzc];
							
							
							}else{
							
								//Ext.Msg.alert("温馨提示",slider.title+"已≤0,系统将按0计算");
							
								label=['应收账款','预付款项','应收利息','应收股利','其他应收款','存货','一年内到期的非流动资金','其他流动资金'];
				
								value=[yszk,yfkx,yslx,ysgl,'0',ch,ynn,qtldzc];
							}	
							
	
		 					create2DPie("chart3",label,value,"pie3",0,1);		
							create2DPies("chart33",label,value,"newpie3",1);
							
					},
					change : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJYXZC();

					},
					scope : this
				}
			});		
					
		//存货
		var chobj = new Ext.slider.SingleSlider({
				renderTo : 'chId',
				id : 'ch',
				width : 100,
				anchor : '100%',
				increment : 1,
				minValue : -500000,
				maxValue :500000,
				value : ch,
				title:'存货',
				listeners : {
					dragend : function(slider, e, eOpts) {
							updateSelfInput(slider);
							updateJYXZC();

					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJYXZC();
							
								//应收账款
							yszk =$("#yszkIdinput").val().replace(reg,"") - 0;
							yszk = yszk < 0 ? '0' : yszk ;
							
							//其他应收款
							qtysk = $("#qtyskIdinput").val().replace(reg,"") - 0;
							qtysk = qtysk < 0 ? '0' : qtysk;
							
							
							//存货
							ch = slider.getValue();
							ch = ch < 0 ? 0 : ch ;
							
							//alert(ch)
							
							if(ch > 0 ){
							
								label=['应收账款','预付款项','应收利息','应收股利','其他应收款','存货','一年内到期的非流动资金','其他流动资金'];
				
								value=[yszk,yfkx,yslx,ysgl,qtysk,ch,ynn,qtldzc];
							
							
							}else{
							
								//Ext.Msg.alert("温馨提示",slider.title+"已≤0,系统将按0计算");
							
								label=['应收账款','预付款项','应收利息','应收股利','其他应收款','存货','一年内到期的非流动资金','其他流动资金'];
				
								value=[yszk,yfkx,yslx,ysgl,qtysk,ch,ynn,qtldzc];
							}	
							
	
		 					create2DPie("chart3",label,value,"pie3",0,1);		
							create2DPies("chart33",label,value,"newpie3",1);
							
							

					},
					change : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJYXZC();

					},
					scope : this
				}
			});			
			
		//应付账款
			var yfzkobj = new Ext.slider.SingleSlider({
				renderTo : 'yfzkId',
				id : 'yfzk',
				width : 100,
				anchor : '100%',
				increment : 1,
				title:'应付账款',
				minValue : -500000,
				maxValue :500000,
				value : yfzk,
				listeners : {
					dragend : function(slider, e, eOpts) {
							updateSelfInput(slider);
							updateJYXFZ();

					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							
							yfzk = slider.getValue(),
		 					yfzk = yfzk < 0 ? 0 : yfzk;
		 					
		 					yfzgxc= $("#yfygxcIdinput").val().replace(reg,"") - 0,
		 					yfzgxc = yfzgxc < 0 ? 0 : yfzgxc;
		 					
		 					qtysk= $("#qtyskIdinput").val().replace(reg,"") - 0,
		 					qtysk = qtysk < 0 ? 0 : qtysk;
		 					
		 					if(yfzk > 0 ){
		 						
		 							label=['应付账款','预收款项','应付职工薪酬','应交税费','应付利息','应付股利','其他应付款','一年内到期的非流动负债','其他流动负债'];
			
									value=[yfzk,yfkx,yfzgxc,yjsf,yflx,yfgl,qtyfk,ynnn,qtldfz];
		 					
		 					}else{
		 						
			 						//Ext.Msg.alert("温馨提示",slider.title+"已≤0,系统将按0计算");
			 						
			 						label=['应付账款','预收款项','应付职工薪酬','应交税费','应付利息','应付股利','其他应付款','一年内到期的非流动负债','其他流动负债'];
				
									value=[yfzk,yfkx,yfzgxc,yjsf,yflx,yfgl,qtyfk,ynnn,qtldfz];
		 					
		 					
		 					}
		 				
							create2DPie("chart4",label,value,"pie4",0,4);
							create2DPies("chart44",label,value,"newpie4",1);
							updateJYXFZ();

					},
					change : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJYXFZ();

					},
					scope : this
				}
			});			
		
		
		//应付员工薪酬
		var yfygxcobj = new Ext.slider.SingleSlider({
				renderTo : 'yfygxcId',
				id : 'yfygxc',
				width : 100,
				anchor : '100%',
				increment : 1,
				title:'应付职工薪酬',
				minValue : -500000,
				maxValue :500000,
				value : yfzgxc,
				listeners : {
					dragend : function(slider, e, eOpts) {
							updateSelfInput(slider);
							updateJYXFZ();

					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJYXFZ();
							
							
							yfzk = $("#yfzkIdinput").val().replace(reg,"") - 0,
		 					yfzk = yfzk < 0 ? 0 : yfzk;
		 					
		 					yfzgxc=  slider.getValue(),
		 					yfzgxc = yfzgxc < 0 ? 0 : yfzgxc;
		 					
		 					qtyfk= $("#qtyfkIdinput").val().replace(reg,"") - 0,
		 					qtyfk = qtysk < 0 ? 0 : qtysk;
		 					
		 					if(yfzgxc > 0){
		 						
		 							label=['应付账款','预收款项','应付职工薪酬','应交税费','应付利息','应付股利','其他应付款','一年内到期的非流动负债','其他流动负债'];
			
									value=[yfzk,yfkx,yfzgxc,yjsf,yflx,yfgl,qtyfk,ynnn,qtldfz];
		 					
		 					}else{
		 						
			 						//Ext.Msg.alert("温馨提示",slider.title+"已≤0,系统将按0计算");
			 						
			 						label=['应付账款','预收款项','应付职工薪酬','应交税费','应付利息','应付股利','其他应付款','一年内到期的非流动负债','其他流动负债'];
				
									value=[yfzk,yfkx,yfzgxc,yjsf,yflx,yfgl,qtyfk,ynnn,qtldfz];
		 					
		 					
		 					}
		 				
							create2DPie("chart4",label,value,"pie4",0,4);
							create2DPies("chart44",label,value,"newpie4",1);
					},
					change : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJYXFZ();

					},
					scope : this
				}
			});			
			
			
		
		
		//其他应付款
		var qtyfkobj = new Ext.slider.SingleSlider({
				renderTo : 'qtyfkId',
				id : 'qtyfk',
				width : 100,
				anchor : '100%',
				increment : 1,
				title:'其他应付款',
				minValue : -500000,
				maxValue :500000,
				value :qtyfk,
				listeners : {
					dragend : function(slider, e, eOpts) {
							updateSelfInput(slider);
							updateJYXFZ();

					},
					changecomplete : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJYXFZ();
							
							
							yfzk = $("#yfzkIdinput").val().replace(reg,"") - 0,
		 					yfzk = yfzk < 0 ? 0 : yfzk;
		 					
		 					yfzgxc= $("#yfygxcIdinput").val().replace(reg,"") - 0,
		 					yfzgxc = yfzgxc < 0 ? 0 : yfzgxc;
		 					
		 					qtyfk= slider.getValue(),
		 					qtyfk = qtyfk < 0 ? 0 : qtyfk;
		 					
		 					if(qtyfk > 0){
		 						
		 							label=['应付账款','预收款项','应付职工薪酬','应交税费','应付利息','应付股利','其他应付款','一年内到期的非流动负债','其他流动负债'];
			
									value=[yfzk,yfkx,yfzgxc,yjsf,yflx,yfgl,qtyfk,ynnn,qtldfz];
		 					
		 					}else{
		 						
			 						//Ext.Msg.alert("温馨提示",slider.title+"已≤0,系统将按0计算");
			 						
			 						label=['应付账款','预收款项','应付职工薪酬','应交税费','应付利息','应付股利','其他应付款','一年内到期的非流动负债','其他流动负债'];
				
									value=[yfzk,yfkx,yfzgxc,yjsf,yflx,yfgl,qtyfk,ynnn,qtldfz];
		 					
		 					
		 					}
		 					create2DPie("chart4",label,value,"pie4",0,4);
		 					create2DPies("chart44",label,value,"newpie4",1);

					},
					change : function(slider, newValue, thumb, eOpts) {
							updateSelfInput(slider);
							updateJYXFZ();

					},
					scope : this
				}
			});				
				
		//
	
	
		// 结构性负债
		var jgxfzproobj = new Ext.ProgressBar({
			renderTo : "jgxfzId",
			id : 'jgxfz',
			width : 130,
			//value:0.7,
			cls:'progressBar',
			minValue : -10000,
			maxValue : 100000

		});
		//jgxfzproobj.updateProgress(progressValue(jgxfzproobj,jgxfz), false);
		initProgressBar(jgxfzproobj,jgxfz);
		//updateTestYYZJXQ(yyzjxq);
		//结构性资产
		var jgxzcproobj = new Ext.ProgressBar({
			renderTo : "jgxzcId",
			id : 'jgxzc',
			width : 130,
			cls:'progressBar',
			minValue : -10000,
			maxValue : 100000

		});
		//jgxfzproobj.updateProgress(progressValue(jgxfzproobj,jgxfz), false);
		
		
		initProgressBar(jgxzcproobj,jgxzc);
		//经营性资产
		var jyxzcproobj = new Ext.ProgressBar({
			renderTo : "jyxzcId",
			id : 'jyxzc',
			width : 130,
			cls:'progressBar',
			minValue : -10000,
			maxValue : 100000

		});
		initProgressBar(jyxzcproobj,jyxzc);
		//经营性负债
		var jyxfzproobj = new Ext.ProgressBar({
			renderTo : "jyxfzId",
			id : 'jyxfz',
			width : 130,
			cls:'progressBar',
			minValue : -1900000,
			maxValue : 800000

		});
		
		
		
		initProgressBar(jyxfzproobj,jyxfz);	
		//营运资本
		var yyzbproobj = new Ext.ProgressBar({
			renderTo : "yyzbId",
			id : 'yyzb',
			width : 130,
			cls:'progressBar',
			minValue : -10000,
			maxValue : 100000

		});
		
		if(yyzb < 0){
			
			$("#yyzbsspan").html(formatNumber(yyzb,2));
			$("#yyzbsspan").css("color","red");
			
		}else{
		
			$("#yyzbsspan").html(formatNumber(yyzb,2));
			$("#yyzbsspan").css("color","green");
				
		}
		//$("#yyzbsspan").html(setDataColor(formatNumber(yyzb,2)));
//		
		initProgressBar(yyzbproobj,yyzb);	
		yyzb > 0 ? str="<font style='color:green;font-weight:bold;font-size:13px;'>投融资活动是协调的</font>":str="<font style='color:red;font-weight:bold;font-size:13px'>投融资活动存在资金缺口，并需要占用流动资金为"+Math.round(Math.abs(yyzb),2)+"</font>";	
	
		$("#h1").html(str);
		//营运资金需求
		var yyzjxqproobj = new Ext.ProgressBar({
			renderTo : "yyzjxqId",
			id : 'yyzjxq',
			width : 130,
			cls:'progressBar',
			minValue : -10000000,
			maxValue : 100000000

		});
		
		
		initProgressBar(yyzjxqproobj,yyzjxq);
		yyzjxq < 0 ?str="<font style='color:green;font-weight:bold;font-size:13px;'>经营活动是协调的</font>":str="<font style='color:red;font-weight:bold;font-size:13px'>经营活动存在资金缺口为"+Math.round(Math.abs(yyzjxq),2)+"</font>";	

		$("#h2").html(str);
		
	
		label=['可供出售金融资产','持有至到期投资','长期应收款','长期股权投资','投资性房地产','固定资产','在建工程','工程物资','固定资产清理','生产性生物资产','油气资产','无形资产','开发支出','商誉','长期待摊费用','递延所得税资产','其他非流动资产'];

		value=[kgcsjrzc,cyzdqtz,cqysk,cqgqtz,tzxfdc,gdzc,zjgc,gcwz,gdzcql,scxswzc,yqzc,wxzc,kfzc,sy,cqdtfy,dysdszc,qtfldzc];
	
		create2DPie("chart1",label,value,"pie1",0,1);
		create2DPies("chart11",label,value,"newpie1",1);
		
		
		label=['实收资本','资本公积','减：库存股','盈余公积','未分配利润','*少数股东权益','长期借款','应付债券','长期应付款','专项应付款','预计负债','递延所得税负债','其他非流动负债'];
		
		value=[sszb,zbgj,jkcg,yygj,wfplr,ssgdqy,cqjk,yfzq,cqyfk,zxyfk,yjfz,dysdsfz,qtfldfz];
	
		create2DPie("chart2",label,value,"pie2",0,2);
		create2DPies("chart22",label,value,"newpie2",1);
		
		label=['应收账款','预付款项','应收利息','应收股利','其他应收款','存货','一年内到期的非流动资金','其他流动资金'];
		
		value=[yszk,yfkx,yslx,yslx,ysgl,qtysk,ch,ynn,qtldzc];
	
		create2DPie("chart3",label,value,"pie3",0,3);
		create2DPies("chart33",label,value,"newpie3",1);
	
		//经营性负债：应付账款+预收款项+应付职工薪酬+应交税费+ 应付利息+ 应付股利+其他应付款+一年内到期的非流动负债+其他流动负债（资产负债表期末数)
		
		label=['应付账款','预收款项','应付职工薪酬','应交税费','应付利息','应付股利','其他应付款','一年内到期的非流动负债','其他流动负债'];
	
		value=[yfzk,yfkx,yfzgxc,yjsf,yflx,yfgl,qtyfk,ynnn,qtldfz];
	
		create2DPie("chart4",label,value,"pie4",0,4);
		create2DPies("chart44",label,value,"newpie4",1);
	
		
		createAngular("angulr1",xjzfnl,"xjzfnlId");

		
		label=['A公司','B公司','C公司','D公司','其他公司'];
		
		//value = 18888,
		
		
		
		
		win1 = new Ext.Window({
				id:"p1",
				modal:true,
				contentEl:'p1',
				closeAction:'hide',
			    title: '结构性资金面占用构成图',
			 
			    height: 550,
			    width: 750,
			    layout: 'fit',
			    bodyStyle: {
    				background: '#fff'
			}
		});
		win2 = new Ext.Window({
				id:"p2",
				modal:true,
				contentEl:'p2',
				closeAction:'hide',
			    title: '结构性负债面来源构成图',
			 
			    height: 530,
			    width: 710,
			    layout: 'fit',
			    bodyStyle: {
    				background: '#fff'
			}
		});
	win3 = new Ext.Window({
				id:"p3",
				modal:true,
				contentEl:'p3',
				closeAction:'hide',
			    title: '经营性资金面占用构成图',
			 
			    height: 530,
			    width: 710,
			    layout: 'fit',
			    bodyStyle: {
    				background: '#fff'
			}
		});
		win4 = new Ext.Window({
				id:"p4",
				modal:true,
				contentEl:'p4',
				closeAction:'hide',
			    title: '经营性负债面来源构成图',
			 
			    height: 530,
			    width: 710,
			    layout: 'fit',
			    bodyStyle: {
    				background: '#fff'
			}
		});
	str = "<font style='color:red;font-weight:bold;font-size:13px;'>严重不协调</font>";
	
	if(xjzfnl > 0){
	
			if(yyzjxq >0){
		
				if(yyzb > 0 && yyzb > yyzjxq){
				
					str = "<font style='color:green;font-weight:bold;font-size:13px;'>协调且有支付能力</font>";
				
				}
				
			}else{
			
				if(yyzb > 0){
				
					str = "<font style='color:green;font-weight:bold;font-size:13px;'>资金大量富裕</font>";	
				
				}else if(Math.abs(yyzb) < Math.abs(yyzjxq)){
		
					str = "<font style='color:green;font-weight:bold;font-size:13px;'>不协调但能够维持</font>";	
				}
					
			}
		
	}else{
		
		if(yyzjxq < 0){
		
				if(yyzb < 0 && Math.abs(yyzb) > Math.abs(yyzjxq)){
					str = "<font style='color:red;font-weight:bold;font-size:13px;'>不协调</font>";	
				}
			
		
			
		}else{
		
			if(yyzb > 0 && yyzb < yyzjxq){
			
					str = "<font style='color:red;font-weight:bold;font-size:13px;'>协调但有支付困难</font>";	
			
			}
		
		}
		
	}
	
	$("#h4").html(str);

		$("input").focus(function(obj){
			
					var val = this.value.replace(reg,"");
					
					//val = val.replace("￥","");
					$(this).val(val)
			})
			
			$("input").blur(function(obj){
			
					var tr  = labelChange(this);
				
					if(tr == true){
						
						var val = formatNumber(this.value,2);
						
						$(this).val(val)
						
					}else{
					
						return false;
						
					}			
					
			});
			
		
		
		}
	
	

	
function initProgressBar(obj,value){

	if(value< 0){
	
		 obj.removeClass("progressBar");
		
		 obj.addClass("progressBar1");
	
	}else{
	
		  obj.removeClass("progressBar1");
		
		  obj.addClass("progressBar");
	}
	
	
		obj.updateProgress(progressValue(obj,value),false);
	

}	
	

function formateData(id, value) {

	value < 0 ? $("#" + id).css("color", "red") : $("#" + id).css("color",
			"green")

	$("#" + id).val(formatNumber(value,2));

}


function initInputData(){
	
	//初始化input中value
		
		$("#kgcsjrzcIdinput").val(formatNumber(kgcsjrzc,2));
		$("#kgcsjrzcIdinput").css('color',kgcsjrzc>0?'green':'red');

		$("#gdzcIdinput").val(formatNumber(gdzc,2));
		$("#gdzcIdinput").css('color',gdzc>0?'green':'red');
		
		$("#wxzcIdinput").val(formatNumber(wxzc,2));
		$("#wxzcIdinput").css('color',wxzc>0?'green':'red');
		
		$("#cqjdIdinput").val(formatNumber(cqjk,2));
		$("#cqjdIdinput").css('color',cqjk>0?'green':'red');
		
		$("#gbIdinput").val(formatNumber(gb,2));
		$("#gbIdinput").css('color',gb>0?'green':'red');
		
		$("#wfplrIdinput").val(formatNumber(wfplr,2));
		$("#wfplrIdinput").css('color',wfplr>0?'green':'red');
		
		
		$("#yszkIdinput").val(formatNumber(yszk,2));
		$("#yszkIdinput").css('color',yszk>0?'green':'red');
		
		$("#qtyskIdinput").val(formatNumber(qtysk,2));
		$("#qtyskIdinput").css('color',qtysk>0?'green':'red');
		
		$("#chIdinput").val(formatNumber(ch,2));
		$("#chIdinput").css('color',ch>0?'green':'red');
		
		$("#yfzkIdinput").val(formatNumber(yfzk,2));
		$("#yfzkIdinput").css('color',yfzk>0?'green':'red');
		//
		$("#yfygxcIdinput").val(formatNumber(yfzgxc,2));
		$("#yfygxcIdinput").css('color',yfzgxc>0?'green':'red');
		
		$("#qtyfkIdinput").val(formatNumber(qtyfk,2));
		$("#qtyfkIdinput").css('color',qtyfk>0?'green':'red');
	
	//初始化span 
		
		//--结构性
		$("#jgxfzspan").html(setDataColor(formatNumber(jgxfz,2)));
		//$("#jgxfzspan").css('color',jgxfz>0?'green':'red');
		$("#jgxzcspan").html(setDataColor(formatNumber(jgxzc,2)));
		//--经营性
		$("#jyxfzspan").html(setDataColor(formatNumber(jyxfz,2)));
		$("#jyxzcspan").html(setDataColor(formatNumber(jyxzc,2)));
	
		
	//初始化营运资本
		

		
		
	//初始化营运资金需求
		
		$("#yyzjxqspan").html(setDataColor(formatNumber(yyzjxq,2)));
		
		
		
	}
	
//更新结构性负债
function updateJGXFZ(){

	//结构性负债：实收资本+资本公积-减：库存股+盈余公积+未分配利润+*少数股东权益+长期借款+应付债券+长期应付款+专项应付款+预计负债+递延所得税负债+其他非流动负债（资产负债表期末数）

	obj = Ext.getCmp("jgxfz"),
	//结构性负债：实收资本+资本公积-减：库存股+盈余公积+未分配利润+*少数股东权益+长期借款+应付债券+长期应付款+专项应付款+预计负债+递延所得税负债+其他非流动负债（资产负债表期末数）
	jgxfz = sszb + zbgj - jkcg + yygj + ($("#wfplrIdinput").val().replace(reg,"") - 0 ) + ($("#gbIdinput").val().replace(reg,"") - 0) + ($("#cqjdIdinput").val().replace(reg,"") - 0) + yfzq+cqyfk+zxyfk+yjfz+dysdsfz+qtfldfz;
	
	if(jgxfz< 0){
	
		 obj.removeClass("progressBar");
		
		 obj.addClass("progressBar1");
	
	}else{
	
		 obj.removeClass("progressBar1");
		
		 obj.addClass("progressBar");
	}

	formateSpanData("jgxfzspan",jgxfz)
	
	obj.updateProgress(progressValue(obj, jgxfz), false);

	updateYYCB();

}

//更新结构性资产
function updateJGXZC(){

	//结构性资产：可供出售金融资产+持有至到期投资+长期应收款+长期股权投资+投资性房地产+固定资产+在建工程+工程物资+固定资产清理+生产性生物资产+油气资产+无形资产+开发支出+商誉+长期待摊费用+递延所得税资产+其他非流动资产（资产负债表期末数）
		
	//结构性资产：可供出售金融资产+持有至到期投资+长期应收款+长期股权投资+投资性房地产+固定资产+在建工程+工程物资+固定资产清理+生产性生物资产+油气资产+无形资产+开发支出+商誉+长期待摊费用+递延所得税资产+其他非流动资产（资产负债表期末数）
	jgxzc =( $("#kgcsjrzcIdinput").val().replace(reg,"") - 0 )+cyzdqtz+cqysk+cqgqtz+tzxfdc+( $("#gdzcIdinput").val().replace(reg,"") - 0 )+zjgc+gcwz+gdzcql+scxswzc+yqzc+( $("#wxzcIdinput").val().replace(reg,"") - 0 )+kfzc+sy+cqdtfy+dysdszc+qtfldzc,
	obj = Ext.getCmp("jgxzc");
	
	if(jgxzc< 0){
	
		 obj.removeClass("progressBar");
		
		 obj.addClass("progressBar1");
	
	}else{
	
		 obj.removeClass("progressBar1");
		
		 obj.addClass("progressBar");
	}
	
	formateSpanData("jgxzcspan",jgxzc);
	obj.updateProgress(progressValue(obj,jgxzc), false);

	updateYYCB();
}

//更新营运成本
function updateYYCB(){

	//营运资本：结构性负债-结构性资产
	jgxfz = $("#jgxfzspan").text().replace(reg,"") - 0,
	
	jgxzc = $("#jgxzcspan").text().replace(reg,"") - 0,
	
	yyzb = jgxfz - jgxzc;
	
	
	
	obj = Ext.getCmp("yyzb");
	
	if(yyzb < 0){
	
		 obj.removeClass("progressBar");
		
		 obj.addClass("progressBar1");
	
	}else{
	
		 obj.removeClass("progressBar1");
		
		 obj.addClass("progressBar");
	}
	
	formateSpanData("yyzbsspan",yyzb);
	obj.updateProgress(progressValue(obj,yyzb), false);
	
	updateTestYYCB(yyzb);
	
	updateXJZFNL();
	
}

//更新经营性资产
function updateJYXZC(){

	//经营性资产：应收账款+ 预付款项+应收利息+ 应收股利+其他应收款+存货+一年内到期的非流动资产+其他流动资产	
		//jyxzc = yszk 
		jyxzc =( $("#yszkIdinput").val().replace(reg,"") - 0 ) + + yfkx + yslx + ysgl +( $("#qtyskIdinput").val().replace(reg,"") - 0 ) + ( $("#chIdinput").val().replace(reg,"") - 0 ) + ynn + qtldzc,
	
		obj = Ext.getCmp("jyxzc");
		
		if(jyxzc < 0){
	
		 obj.removeClass("progressBar");
		
		 obj.addClass("progressBar1");
	
		}else{
	
		 obj.removeClass("progressBar1");
		
		 obj.addClass("progressBar");
		}
		
		
		formateSpanData("jyxzcspan",jyxzc);
		
		obj.updateProgress(progressValue(obj,jyxzc), false);

		updateYYZJXQ();
		
}

//更新经营性负债
function updateJYXFZ(){
	/*
	 * 经营性负债：应付账款+预收款项+应付职工薪酬+应交税费+ 应付利息+ 应付股利+其他应付款+一年内到期的非流动负债+其他流动负债（资产负债表期末数）
	 */
	jyxfz =( $("#yfzkIdinput").val().replace(reg,"") - 0 ) + yfkx + ( $("#yfygxcIdinput").val().replace(reg,"") - 0 ) + yjsf + yflx + yfgl +( $("#qtyfkIdinput").val().replace(reg,"") - 0 ) + ynnn + qtldfz,
	
	obj = Ext.getCmp("jyxfz");
	
	if(jyxfz < 0){
	
		 obj.removeClass("progressBar");
		
		 obj.addClass("progressBar1");
	
		}else{
	
		 obj.removeClass("progressBar1");
		
		 obj.addClass("progressBar");
		}
		
		
		
	formateSpanData("jyxfzspan",jyxfz);
		
	obj.updateProgress(progressValue(obj,jyxfz), false);

	updateYYZJXQ();
	
}
//更新营运资金需求
function updateYYZJXQ(){

	//营运资金需求：经营性资产-经营性负债
	
	yyzjxq = ( $("#jyxzcspan").text().replace(reg,"") - 0 ) - ( $("#jyxfzspan").text().replace(reg,"") - 0 ),
	
	obj = Ext.getCmp("yyzjxq");
	
	if(yyzjxq < 0){
	
		 obj.removeClass("progressBar");
		
		 obj.addClass("progressBar1");
	
		}else{
	
		 obj.removeClass("progressBar1");
		
		 obj.addClass("progressBar");
		}
		
	
	
	formateSpanData("yyzjxqspan",yyzjxq);
		
	obj.updateProgress(progressValue(obj,yyzjxq), false);
	
	updateTestYYZJXQ(yyzjxq);
	
	updateXJZFNL();
	
}
//更新现金支付能力
function updateXJZFNL(){

	xjzfnl =( $("#yyzbspan").text().replace(reg,"") - 0 )- ( $("#yyzjxqspan").text().replace(reg,"") - 0);
	
	updateXJZFNLText();
	
	CnbiSoft("angulr1").setData(1,xjzfnl/10000);
	
}

function updateTestYYCB(yycb){
	//IF(营运资本>0,"投融资活动是协调的","投融资活动存在资金缺口，并需要占用流动资金为："&ROUND(ABS(营运资本),2))
		
	yycb > 0 ? str="<font style='color:green;font-weight:bold;font-size:13px;'>投融资活动是协调的</font>":str="<font style='color:red;font-weight:bold;font-size:13px'>投融资活动存在资金缺口，并需要占用流动资金为"+Math.round(Math.abs(yycb),2)+"</font>";	
	
	$("#h1").html(str);
}
function updateTestYYZJXQ(yyzjxq){

	//营运资金需求文字：=IF(营运资金需求<0,"经营活动是协调的","经营活动存在资金缺口为:"&ROUND(营运资金需求,2))
	yyzjxq < 0 ?str="<font style='color:green;font-weight:bold;font-size:13px;'>经营活动是协调的</font>":str="<font style='color:red;font-weight:bold;font-size:13px'>经营活动存在资金缺口为"+Math.round(Math.abs(yyzjxq),2)+"</font>";	

	$("#h2").html(str);
}

function updateXJZFNLText(){

	/*
	 * 
	 * IF(AND(现金支付能力<0, 营运资金需求<0, 营运资本<0,ABS(营运资本)>ABS(营运资金需求)),"不协调",
	 * IF(AND(现金支付能力<0,营运资金需求>0,营运资本>0,营运资本<营运资金需求),"协调但有支付困难","严重不协调")))))
	 */
	
	yyzb = $("#yyzbspan").text().replace(reg,"") - 0 ,
	
	yyzjxq = $("#yyzjxqspan").text().replace(reg,"") - 0,
	//获取现金支付能力
	xjzfnl =yyzb - yyzjxq ;
	
	str = "<font style='color:red;font-weight:bold;font-size:13px;'>严重不协调</font>";
	
	if(xjzfnl > 0){
	
			if(yyzjxq >0){
		
				if(yyzb > 0 && yyzb > yyzjxq){
				
					str = "<font style='color:green;font-weight:bold;font-size:13px;'>协调且有支付能力</font>";
				
				}
				
			}else{
			
				if(yyzb > 0){
				
					str = "<font style='color:green;font-weight:bold;font-size:13px;'>资金大量富裕</font>";	
				
				}else if(Math.abs(yyzb) < Math.abs(yyzjxq)){
		
					str = "<font style='color:green;font-weight:bold;font-size:13px;'>不协调但能够维持</font>";	
				}
					
			}
		
	}else{
		
		if(yyzjxq < 0){
		
				if(yyzb < 0 && Math.abs(yyzb) > Math.abs(yyzjxq)){
					str = "<font style='color:red;font-weight:bold;font-size:13px;'>不协调</font>";	
				}
			
		
			
		}else{
		
			if(yyzb > 0 && yyzb < yyzjxq){
			
					str = "<font style='color:red;font-weight:bold;font-size:13px;'>协调但有支付困难</font>";	
			
			}
		
		}
		
	}
	
//	style="text-align: center"
	$("#h4").html(str);
	
	//$("#h4").css("text-align","center")
}

function getSliderValue(id){

	val = Ext.getCmp(id).getValue();
	
	if(val < 0){
	
		val= 0 ;
	
	}
	
	return val;

}



function formateSpanData(id, value) {

	value < 0 ? $("#" + id).css("color", "red") : $("#" + id).css("color",
			"green");
			
	$("#" + id).text(formatNumber(value,2));

}



function progressValue(a, values) {

	var min = a.minValue, max = a.maxValue, value = 0;

	// alert(min+"--"+min)
	if (values > 0) {

		value = 0.5 + values / (2 * max);

		if (value > 1) {

			value = 1;

		}

	}
	if (values == 0) {
		value = 0.5;
		if (min == 0) {
			value = 0;
		}

	}
	if (values < 0) {
		value = 0.5 - Math.abs(values / (2 * min));
		if (value < 0)
			value = 0;

	}

	return value;
};	
	
	
//创建仪表盘
function createAngular(chartobjId,value,domId){
	
	CnbiSoft.setCurrentRenderer("JavaScript");
	
	var charts = new CnbiSoft("fw/Charts/AngularGauge.swf",chartobjId,"80%","23.3%","0","1");
	
	var p = '<chart manageResize="1" origW="415" origH="415"  manageValueOverlapping="1" showValue="1" autoAlignTickValues="1"     tickValueDistance="1" bgColor="FFFFFF" upperLimit="5000" lowerLimit="0" numberSuffix="" baseFontColor="000000"  majorTMNumber="11" majorTMColor="000000"  majorTMHeight="30" minorTMNumber="5" minorTMColor="000000" minorTMHeight="15" showGaugeBorder="0" gaugeOuterRadius="170" gaugeInnerRadius="140" gaugeOriginX="210" gaugeOriginY="210" gaugeAlpha="50" placeValuesInside="1" toolTipBgColor="FFFFFF" toolTipBorderColor="CCCCCC" gaugeFillMix="" showShadow="0" annRenderDelay="0" pivotRadius="18" pivotFillMix="{E6E6E6},{999999}" pivotBorderColor="bebcb0" pivotFillRatio="70,30" showTickValues="0" showBorder="0" gaugeStartAngle="230" gaugeEndAngle="-50"  >\n\
	<colorRange>\n\
		<color minValue="0" maxValue="3000" code="FF0000" />\n\
		<color minValue="3000" maxValue="4000" code="ffff00" />\n\
		<color minValue="4000" maxValue="5000" code="00ff00" />\n\
	</colorRange>\n\
	<dials>\n\
		<dial value="'+value+'" bgColor="000000,4D4D4D" borderAlpha="0" baseWidth="20" topWidth="1" rearExtension="50" valueY="333" radius="150"/>\n\
	</dials>\n\
	<!-- To draw the pre built custom objects -->\n\
	<annotations>\n\
		<!-- To draw it below the chart-->\n\
		<annotationGroup x="210" y="210" showBelow="1">\n\
			<!-- To draw the outer blue dial with gradient effect-->\n\
			<annotation  type="circle" x="0" y="0" radius="200" fillColor="35BADC,35BDDF, C5F4FF"  fillRatio="80,15, 5" borderColor="35BADC" />\n\
			<!-- To fill the dial with gradient effect-->\n\
			<annotation type="circle" x="0" y="0" radius="190" fillColor="FFFFFF, FFFFFF" fillRatio="20,80" borderColor="FFFFFF" />\n\
			<!-- To draw the green arc circling the outer dial-->\n\
			<annotation type="circle" x="0" y="0" radius="190"  fillColor="E6E6E6, FFFFFF" fillAlpha="50" borderColor="E6E6E6" />\n\
		</annotationGroup>\n\
	</annotations>\n\
	<styles>' +
			'<definition>' +
			'<style type="font" name="a" bgColor="FF0000" size="20" borderColor="FF0000"  baseFontColor="FF0000" />' +
			'<style name="MyFirstBevel" type="Bevel" />'+
			'</definition>' +
			'<application>' +
			'<apply toObject="Value" styles="a"/>' +
				'<apply toObject="Value" styles="MyFirstBevel"/>' +
			'</application> ' +
			'</styles></chart>'; 
	
	charts.setXMLData(p);
	
	charts.render(domId);
	
}

function updateSelfInput(slider) {

	var val = slider.getValue();

	var sliderId = slider.id;

	var inputId = sliderId + "Idinput";

	//alert(inputId)
	
	formateData(inputId, val)
}
//创建2D饼图

function create2DPie(chartobjId,label,value,domId,tf){

	CnbiSoft.setCurrentRenderer("JavaScript");
	
	var chartpie ;
	
	if(CnbiSoft(chartobjId)){
		
		chartpie = 	CnbiSoft(chartobjId);
		
	}else{
		
		chartpie = new CnbiSoft("fc/Charts/Pie2D.swf",chartobjId,"240","240","0","1");
		
	}
	
	 
	
	var set="";

	for(var i = 0 ; i < label.length ; i++){
		
		st = label[i]+","+usMoney(value[i]),
		
      	str = "j-createDialog-"+3,
 
		set += '<set label="'+st+'" value="'+value[i]+'" link="'+str+'"/>';
		
	}
	
	
	var p = '<chart manageResize="1"  showLabels="0" chartLeftMargin="0"  legendIconScale="0.8" legendAllowDrag="0" minimiseWrappingInLegend="0" showBorder="0" legendPosition="RIGHT" chartTopMargin="0"  bgColor="ffffff" bgAlpha="0,0"  showValues="0" isSmartLineSlanted="1"  showLegend="0">'+set+'' +
			
			'</chart>';
	
	chartpie.setXMLData(p);

	chartpie.render(domId);
}
function usMoney  (v) {
			
			v = (Math.round((v - 0) * 100)) / 100;
			v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v
					* 10)) ? v + "0" : v);
			v = String(v);
			var ps = v.split("."), whole = ps[0], sub = ps[1]
					? "." + ps[1]
					: ".00", r = /(\d+)(\d{3})/;
			while (r.test(whole)) {
				whole = whole.replace(r, "$1,$2")
			}
			v = whole + sub;
			if (v.charAt(0) == "-") {
				return  v.substr(1)
			}
			return  v
		}
		
function formatNumber(num,cent){
		
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))//检查传入数值为数值类型.
		 num = "0";
		if(isNaN(cent))//确保传入小数位为数值型数值.
		cent = 0;
		cent = parseInt(cent);
		cent = Math.abs(cent);//求出小数位数,确保为正整数.
		
		sign = (num == (num = Math.abs(num)));//获取符号(正/负数)
		//Math.floor:返回小于等于其数值参数的最大整数
		num = Math.floor(num*Math.pow(10,cent)+0.50000000001);//把指定的小数位先转换成整数.多余的小数位四舍五入.
		cents = num%Math.pow(10,cent); //求出小数位数值.
		num = Math.floor(num/Math.pow(10,cent)).toString();//求出整数位数值.
		cents = cents.toString();//把小数位转换成字符串,以便求小数位长度.
		while(cents.length<cent){//补足小数位到指定的位数.
		cents = "0" + cents;
		}
		//对整数部分进行千分位格式化.
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + num + '.' + cents);
	}		
		

	
	
	
function createDialog(val){
	
	$("#p"+val).show();

    var  obj= eval("win"+val);
    
    obj.show();
    
    if(obj){
    
    	obj.restore( ) ;
    	
    	
    }
    
}
function createDialog2(text,val){
	
	var arr = text.split(",");
	
	var content = arr[0]
	
	var value = arr[1];
	
	
	if(content == "应收账款"){
	
//		//饼图按这个：A公司（20%）、B公司（30%）、C公司（10%）、D公司(25%）其他合计(15%)
//		label=['A公司','B公司','C公司','D公司','应付利息','应付股利','其他应付款','一年内到期的非流动负债','其他流动负债'];
	
		label=['A公司','B公司','C公司','D公司','其他公司'];
		
		value=[value*0.2,value*0.3,value*0.1,value*0.25,value*0.15];
//	
//		
		create2DPies("chart55",label,value,"yszkpie",1);
		
		var win5 = Ext.getCmp("p5");
		
		if(win5){
		
			win5.show();
		
		}else{
		
			win5= Ext.create('Ext.window.Window', {
			
				id:"p5",
				modal:true,
				contentEl:'p5',
				closeAction:'hide',
			    title: '应收账款构成图',
			    height: 530,
			    width: 710,
			    layout: 'fit',
			    bodyStyle: {
    				background: '#fff'
				}
		
		});
		
		
		}
		
		
		$("#p5").show();
		
		win5.show();
		
		
//		
		
		//win3.restore(); 
//		
//		$( "#p5" ).dialog( "open" );
		
		
		
		
	}

	
}

function create2DPies(chartobjId,label,value,domId,tf){
	
	
	CnbiSoft.setCurrentRenderer("JavaScript");
	
	var chartpie ;
	
	
	
	if(CnbiSoft(chartobjId)){
		
		chartpie = 	CnbiSoft(chartobjId);
		
	}else{
		
		chartpie = new CnbiSoft("fc/Charts/Pie2D.swf",chartobjId,"700","350","0","1");
		
	}
	
	 
	
	var set="";
	
	
	for(var i = 0 ; i < label.length ; i++){
	
		strs = label[i]+","+value[i];
		
		st = label[i]+","+usMoney(value[i]),
		
      	str = "j-createDialog2-"+strs,
 
		set += '<set label="'+st+'" value="'+value[i]+'" link="'+str+'"/>';
		
	}
	
	
	var p = '<chart manageResize="1"  showLabels="1"  chartTopMargin="60" chartLeftMargin="30"  numberPrefix="￥" formatNumberScale="0" legendAllowDrag="0" minimiseWrappingInLegend="1" showBorder="0" legendPosition="RIGHT"  legendBorderThickness="0" legendBorderColor="ffffff" legendBorderAlpha="100" bgColor="ffffff" bgAlpha="0,0" pieYScale="1000" showValues="1" isSmartLineSlanted="1" pieSliceDepth="100"  showLegend="'+0+'">'+set+'' +
			
			'</chart>';
	
	chartpie.setXMLData(p);

	chartpie.render(domId);
		
}

function labelChange(obj,i) {

	var inputId = obj.id,

	newValue = obj.value.replace(reg, "") - 0,

	sliderId = inputId.replace("Idinput", ""),
	
	//alert(sliderId)

	slider = Ext.getCmp(sliderId),

	value = slider.getValue(),

		//alert(newValue)
	
	min = slider.minValue,

	max = slider.maxValue;

	if (isNaN(newValue - 0 )) {

		alert("亲,填写数据有误!请重新输入!")

		obj.focus();

		$(obj).val(formatNumber(value,2));

		return false;

	} else if (newValue < min) {

		alert("亲,填写数据小于最小值,输入范围应在[" + min + "-" + max + "]之间!请重新输入!")

		obj.focus();

		$(obj).val(formatNumber(value,2));

		return false;

	} else if (newValue > max) {

		alert("亲,填写数据大于最大值,输入范围应在[" + min + "~" + max + "]之间!请重新输入!")
		 //slider.setValue(value)
		//alert(newValue.toFixed(2)+"----")
		
		obj.focus();

		$(obj).val(value);
		
		// obj.val(millon(value));

		return false;

	}else{
	
		 newValue = newValue - 0;
		 
		 slider.setValue(newValue)
		 
		 formateData(inputId,newValue);
		 
		 $(obj).val(formatNumber(newValue,2));

		 if(i == 1){
		 
		 	//可供出售金融资产
		 	kgcsjrzc = $("#kgcsjrzcIdinput").val().replace(reg,"") - 0;
		 	//固定资产
		 	gdzc = $("#gdzcIdinput").val().replace(reg,"") - 0;
		 	//无形资产
		 	wxzc = $("#wxzcIdinput").val().replace(reg,"") - 0;
		 	
		 	label=['可供出售金融资产','持有至到期投资','长期应收款','长期股权投资','投资性房地产','固定资产','在建工程','工程物资','固定资产清理','生产性生物资产','油气资产','无形资产','开发支出','商誉','长期待摊费用','递延所得税资产','其他非流动资产'];

			value=[kgcsjrzc,cyzdqtz,cqysk,cqgqtz,tzxfdc,gdzc,zjgc,gcwz,gdzcql,scxswzc,yqzc,wxzc,kfzc,sy,cqdtfy,dysdszc,qtfldzc];
	
			create2DPie("chart1",label,value,"pie1",0,1);		 	
		 
		 }else if(i == 2){
		 
		 
		 	//长期借款
		 	cqjk = $("#cqjdIdinput").val().replace(reg,"") - 0;
		 	//股本
		 	gb = $("#gbIdinput").val().replace(reg,"") - 0;
		 	//未分配利润
		 	wfplr = $("#wfplrIdinput").val().replace(reg,"") - 0;
		 	
		 	label=['实收资本','资本公积','减：库存股','盈余公积','未分配利润','*少数股东权益','长期借款','应付债券','长期应付款','专项应付款','预计负债','递延所得税负债','其他非流动负债'];
		
			value=[sszb,zbgj,jkcg,yygj,wfplr,ssgdqy,cqjk,yfzq,cqyfk,zxyfk,yjfz,dysdsfz,qtfldfz];
			
			create2DPie("chart2",label,value,"pie2",0,1);		 
		 	
		 
		 }else if(i == 3){
		 	
		 	yszk = $("#yszkIdinput").val().replace(reg,"") - 0,
		 	
		 	qtysk = $("#qtyskIdinput").val().replace(reg,"") - 0,
		 	
		 	ch = $("#chIdinput").val().replace(reg,"") - 0;
		 	
		 	//经营性资产：应收账款+ 预付款项+应收利息+ 应收股利+其他应收款+存货+一年内到期的非流动资产+其他流动资金
			label=['应收账款','预付款项','应收利息','应收股利','其他应收款','存货','一年内到期的非流动资金','其他流动资金'];
			//jyxzc = yszk + yfkx + yslx + ysgl + qtysk + ch + ynn + qtldzc,
			value=[yszk,yfkx,yslx,yslx,ysgl,qtysk,ch,ynn,qtldzc];
	
		 	create2DPie("chart3",label,value,"pie3",0,1);		 
		 		
		 	
		 }else if(i == 4){
		 	
		 		yfzk = $("#yfzkIdinput").val().replace(reg,"") - 0,
		 		
		 		yfzgxc= $("#yfygxcIdinput").val().replace(reg,"") - 0,
		 		
		 		qtysk= $("#qtyskIdinput").val().replace(reg,"") - 0,
		 	
		 		//yfygxcIdinput
				 label=['应付账款','预收款项','应付职工薪酬','应交税费','应付利息','应付股利','其他应付款','一年内到期的非流动负债','其他流动负债'];
			
				value=[yfzk,yfkx,yfzgxc,yjsf,yflx,yfgl,qtyfk,ynnn,qtldfz];
			
				create2DPie("chart4",label,value,"pie4",0,4);
			
		}
		 
		 
		
	}
	
		return true;
		
//		var val = millon(obj.value);
//					//changeLabel(obj);
//		$(obj).val("￥"+val)
	

}



function setDataColor(value){
	if(value < 0 ){return "<font color='red'>"+value+"</font>";}else{return "<font color='green'>"+value+"</font>";}
	}








